package paintball;

import game.Constants;
import game.GameMap;
import game.GameObject;
import game.Player;
import game.Projectile;

import java.util.ArrayList;

public class PaintballBullet extends Projectile {
	//private int stepsToLive = 55;
	public PaintballBullet(int x, int y, double direction, Player owner) {
		super(x, y, direction, owner);
		this.setMoveSpeed(6);
		this.setWidth(10);
		this.setHeight(10);
	}
	
	@Override
	public String curImgPath(){
		return "res/projectile.png";
	}
	
	@Override
	public void step(GameMap map, ArrayList potentialColliders){
//		if(stepsToLive <= 0){
//			this.setActive(false);
//		}
		this.move(map);
		this.collisionCheck(potentialColliders);
		if(this.collidesWithMap(map)){
			this.state = State.DEAD;
			this.setActive(false);
		}
		if(this.getX() < 0 || this.getX() > Constants.screenWidth || this.getY() < 0 || this.getY() > Constants.screenHeight){
			this.state = State.DEAD;
			this.setActive(false);
		}
//		stepsToLive -= 1;
	}
	
	@Override
	public void collisionHandler(GameObject go){
		if(go instanceof Player && this.isActive()){
			if(!go.equals(getOwner()) && go.isActive()){
				this.setActive(false);
				((PaintballPlayer) go).TakeHit(1, this.getOwner().getPlayerName());	
			}
		}
	}
}
